/*
	This file is part of PropExtractor.

	PropExtractor is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	PropExtractor is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with PropExtractor. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _PEALICESOFTARCHIVE_H_
#define _PEALICESOFTARCHIVE_H_


#include "PEFile.h"

namespace pe
{

#define PE_ALICEZIP_TYPE_MODEL    0
#define PE_ALICEZIP_TYPE_TEXTURE  1

	struct AliceArchiveRedHeader
	{
		byte header[4];
		dword padding;
		dword number_of_files;
	};

	struct AliceArchiveRedFileHeader
	{
		dword offset;
		dword size;
		dword type;
	};

	struct AliceArchiveRedFile
	{
		char* path;
		AliceArchiveRedFileHeader* header;
	};

	struct AliceArchiveRed
	{
		wchar_t* workingdir;
		PEStream* handle;

		AliceArchiveRedHeader* header;

		AliceArchiveRedFile* files;
		unsigned int files_total;
	};

	struct PEArchiveRaw;

	PE_EXPORT int AliceArchiveRedReadHeader(AliceArchiveRedHeader* a_Target, PEStream* a_Stream);
	PE_EXPORT int AliceArchiveRedReadData(AliceArchiveRed* a_Target, AliceArchiveRedHeader* a_Header, PEStream* a_Stream);

	PE_EXPORT int AliceArchiveRedOpenFile(PEStream* a_Target, AliceArchiveRed* a_Zip, unsigned int a_Index);
	PE_EXPORT int AliceArchiveRedExtractFile(AliceArchiveRed* a_Zip, unsigned int a_Index, const char* a_Pattern = NULL);

	PE_EXPORT int AliceArchiveRedSaveToFile(AliceArchiveRed* a_ZipFile, unsigned int a_Index, const char* a_Pattern = NULL);
	PE_EXPORT int AliceArchiveRedSaveImageToFile(AliceArchiveRed* a_ZipFile, unsigned int a_Index, const char* a_Pattern = NULL);
	PE_EXPORT int AliceArchiveRedSaveModelToFile(AliceArchiveRed* a_ZipFile, unsigned int a_Index, const char* a_Pattern = NULL);

	PE_EXPORT int AliceArchiveRedToRaw(PEArchiveRaw* a_Target, AliceArchiveRed* a_Archive);

}; // namespace pe

#endif